package com.lightjet.macross.base.awf.service.impl;

import com.lightjet.macross.base.awf.domain.BizFormLog;
import com.lightjet.macross.base.awf.repository.BizFormLogRepository;
import com.lightjet.macross.base.awf.service.BizFormLogService;
import com.lightjet.macross.common.core.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;

/**
 * @author : lijia
 * @version : 1.0 2019-03-19 09:23
 * description :业务表单日志服务接口实现
 */

@Service
public class BizFormLogServiceImpl extends BaseServiceImpl<BizFormLog,Integer> implements BizFormLogService {

    @Override
    public void CreateBizFormLog(HashMap<String, Object> map) {
        BizFormLog bizFormLog = new BizFormLog();
        if(map.containsKey("processkey")&&map.get("processkey")!=null)
        {
            bizFormLog.setProcinstdefId(map.get("processkey").toString());
        }
        if(map.containsKey("procinstId")&&map.get("procinstId")!=null)
        {
            bizFormLog.setProcinstId(map.get("procinstId").toString());
        }
        if(map.containsKey("title")&&map.get("title")!=null)
        {
            bizFormLog.setTitle(map.get("title").toString());
        }
        if(map.containsKey("taskId")&&map.get("taskId")!=null)
        {
            bizFormLog.setTaskId(map.get("taskId").toString());
        }
        if(map.containsKey("executor")&&map.get("executor")!=null)
        {
            bizFormLog.setExecutor(map.get("executor").toString());
        }
        if(map.containsKey("bizformdata")&&map.get("bizformdata")!=null)
        {
            bizFormLog.setBizformdata(map.get("bizformdata").toString());
        }
        if(map.containsKey("bizformclass")&&map.get("bizformclass")!=null)
        {
            bizFormLog.setBizformclass(map.get("bizformclass").toString());
        }
        if(map.containsKey("comments")&&map.get("comments")!=null)
        {
            bizFormLog.setComments(map.get("comments").toString());
        }
        if(map.containsKey("nodename")&&map.get("nodename")!=null)
        {
            bizFormLog.setNodename(map.get("nodename").toString());
        }
        if(map.containsKey("activityId")&&map.get("activityId")!=null)
        {
            bizFormLog.setActivityId(map.get("activityId").toString());
        }
        if(map.containsKey("opdate")&&map.get("opdate")!=null)
        {
            bizFormLog.setOpdate(new Date((Long)map.get("opdate")));
        }
        if(map.containsKey("_id")&&map.get("_id")!=null)
        {
            bizFormLog.setMfId(map.get("_id").toString());
        }

        this.CreateAndFlush(bizFormLog);
    }

    @Override
    public String FindMonggoFormId(String taskid) {
        return ((BizFormLogRepository) baseRepository).findMonggoFormId(taskid);
    }

    @Override
    public String FindLatestTaskIdByPiid(String piid) {
        return ((BizFormLogRepository) baseRepository).findLatestTaskIdByPiid(piid).toString();
    }
}
